<template>
  <div class="app-container">
    <div class="search-container">
      <el-form ref="queryParamsRef" :inline="true" :model="queryParams" label-width="100px">
        <el-form-item label="起止时间" prop="startTime">
          <el-date-picker v-model="dateRange" :unlink-panels="true" end-placeholder="结束日期"
                          range-separator="截止" start-placeholder="开始日期" type="daterange"
                          @change="startTimeChange"></el-date-picker>
        </el-form-item>
        <el-form-item label="清算类型" prop="clr_type">
          <el-select v-model="queryParams.clr_type" class="width-120" placeholder="请选择">
            <el-option v-for=" dict in dictDataMap['clr_type'] " :key="dict.dictValue"
                       :label="dict.dictLabel" :value="dict.dictValue"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="险种" prop="险种">
          <el-select v-model="queryParams.insutype" class="width-120" placeholder="请选择">
            <el-option v-for=" dict in dictDataMap['insutype'] " :key="dict.dictValue"
                       :label="dict.dictLabel" :value="dict.dictValue"></el-option>
          </el-select>
        </el-form-item>
        <div class="mr20" style="float: right">
          <el-button type="primary" @click="handleQuery">对明细账</el-button>
        </div>
      </el-form>
    </div>

    <el-table v-adaptive :border="true" :data="orgCostDetailList" :header-cell-style="$headerCellStyle" :stripe='true'
              highlight-current-row>
      <el-table-column label="门诊/住院号" :align="'center'" prop="hisMdtrtNo" width="100"/>
      <el-table-column label="姓名" :align="'center'" prop="psnName" width="80"/>
      <el-table-column label="医疗费总额" :align="'center'" prop="medfeeSumamt" width="100"/>
      <el-table-column label="基金支付总额" :align="'center'" prop="fundPaySumamt" width="100"/>
      <el-table-column label="个人账户支出" :align="'center'" prop="acctPay" width="100"/>
      <el-table-column label="人员编号" :align="'center'" prop="psnNo" width="200"/>
      <el-table-column label="就诊ID" :align="'center'" prop="mdtrtId" width="100"/>
      <el-table-column label="结算ID" :align="'center'" prop="setlId" width="100"/>
      <el-table-column label="发送方报文" :align="'center'" prop="msgid"  width="230"/>
      <el-table-column label="对账结果" :align="'center'" prop="stmtRslt" width="80"/>
      <el-table-column label="是否退费" :align="'center'" prop="refdSetlFlag" width="80"/>
      <el-table-column label="说明" :align="'center'" prop="memo"/>
    </el-table>
<!--    <pagination
        v-show="total>0"
        :total="total"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        @pagination="handleQuery"
    />-->
  </div>
</template>

<script lang="ts" setup>
import {useDictStoreHook} from "@/store/modules/dict.ts";
import {orgCostDetail} from "@/api/msip/reconciliation.ts";
import {useUserStoreHook} from "@/store/modules/user.ts";
import {ElMessage} from "element-plus";

const useUserStore = useUserStoreHook();
// 登录用户信息
const userInfo = <UserInfoBusi>useUserStore.user.userInfo;
const {proxy} = getCurrentInstance() as any;

const date = proxy.$parseTime(new Date(), "{y}-{m}-{d} ");
const dateRange = ref([date + "00:00:00", date + "23:59:59"]);
const dictStore = useDictStoreHook();
let dictDataMap = ref(dictStore.isTypeGetData('insurance_type','clr_type'))
const orgCostDetailList = ref<any>([])
const total = ref(0)
const queryParams = ref<any>({
 /* pageNum: 1,
  pageSize: 10,*/
  stmt_begndate: "",
  stmt_enddate: "",
  insutype: "",
  clr_type: "",
  org_id: userInfo.orgId,
})

function startTimeChange(e) {
  if (e) {
    dateRange.value = [proxy.$parseTime(e[0], "{y}-{m}-{d} 00:00:00"), proxy.$parseTime(e[1], "{y}-{m}-{d} 23:59:59")]
  }
}

function handleQuery() {
  if (!dateRange.value || dateRange.value.length === 0) {
    ElMessage.error("起止时间不能为空");
    return;
  }
  queryParams.value.stmt_begndate = dateRange.value[0];
  queryParams.value.stmt_enddate = dateRange.value[1];
  orgCostDetail(queryParams.value).then((response: any) => {
    orgCostDetailList.value = response.rows;
    total.value = response.total;
  });
}

</script>
<script lang="ts">
export default {
  name: "ReconciliationItem"
}
</script>

<style scoped>

</style>
